use crate::pool::{ManagedPgConn, Pool};
use r2d2::PooledConnection;

#[derive(Clone)]
pub struct ShareData {
    pool: Pool,
}

impl ShareData {
    pub fn new(pool: Pool) -> Self {
        ShareData { pool }
    }
    pub fn postgres(&self) -> PooledConnection<ManagedPgConn> {
        let pool = self.pool.clone();
        pool.get().expect("获取数据库失败，请检查数据库是否运行！")
    }
}
